#!/bin/bash

# ----------------------------------------------------------------------
# Filename:   75742-ext3.sh
# Version:    1.0
# Date:       2013/11/25
# Author:     yuanhui.shi
# Email:      yuanhui.shi@cs2c.com.cn
# Summary:    04系统兼容性-01文件系统兼容性-02ext3-03验证ext3格式文件编码兼容
# Notes:      ext3文件系统
# Copyright:  China Standard Software Co., Ltd.
# History：     
#             Version 1.0, 2013/11/25
#             -   The first one
# ----------------------------------------------------------------------

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

source ../../lib/Echo.sh
source ./lib/cmd.sh
source ../../lib/XmlParse.sh
source ./lib/Partition_fdisk.sh

function CleanData ()
{
  EchoInfo "卸载分区"
  umount /dir1
  rm -rf /dir1
  EchoInfo "删除分区"
  DeletePartition
  partprobe
  rm -rf /tmp/tmp1
  rm -rf /tmp/tmp2
  EchoInfo "75742-ext3.sh执行完毕"
}

trap "CleanData" EXIT

#Create a partition

CreatePartition

partprobe
# 格式化ext3分区
Partition=`fdisk -l |tail -1 |cut -d " " -f1`
mkfs.ext3 ${Partition}
EchoResult "格式化ext3文件系统分区成功" 

sleep 5

#挂载ext3分区到本地目录
mkdir /dir1
mount ${Partition} /dir1
mount |grep ${Partition}
EchoResult "成功挂载ext3分区到本地目录"

#在挂载分区内创建各种格式文件"

touch /dir1/test.txt
touch /dir1/test.odt
touch /dir1/test.pdf
touch /dir1/测试.txt
touch /dir1/测试.odt
touch /dir1/测试.pdf

test -n `ls /dir1 |grep "test.txt"`
EchoResult "在挂载分区内创建test.txt成功"
test -n `ls /dir1 |grep "test.odt"`
EchoResult "在挂载分区内创建test.odt成功"
test -n `ls /dir1 |grep "test.pdf"`
EchoResult "在挂载分区内创建test.pdf成功"
test -n `ls /dir1 |grep "测试.txt"`
EchoResult "在挂载分区内创建测试.txt成功"
test -n `ls /dir1 |grep "测试.odt"`
EchoResult "在挂载分区内创建测试.odt成功"
test -n `ls /dir1 |grep "测试.pdf"`
EchoResult "在挂载分区内创建测试.pdf成功"
